/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.femass.model;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


@Entity
@Table(name = "Avaliacao")
@NamedQueries({
    @NamedQuery(name = "Avaliacao.findAll", query = "SELECT a FROM Avaliacao a"),
    @NamedQuery(name = "Avaliacao.findByRevisorcod", query = "SELECT a FROM Avaliacao a WHERE a.avalicacaoPK.revisorcod = :revisorcod"),
    @NamedQuery(name = "Avaliacao.findByArtigocod", query = "SELECT a FROM Avaliacao a WHERE a.avalicacaoPK.artigocod = :artigocod"),
    @NamedQuery(name = "Avaliacao.findByNotaC1", query = "SELECT a FROM Avaliacao a WHERE a.avalicacaoPK.notaC1 = :notaC1"),
    @NamedQuery(name = "Avaliacao.findByNotaC2", query = "SELECT a FROM Avaliacao a WHERE a.avalicacaoPK.notaC2 = :notaC2"),
    @NamedQuery(name = "Avaliacao.findByNotaC3", query = "SELECT a FROM Avaliacao a WHERE a.avalicacaoPK.notaC3 = :notaC3")})
public class Avaliacao implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AvaliacaoPK avalicacaoPK;
    @JoinColumn(name = "Revisor_cod", referencedColumnName = "cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Revisor revisor;
    @JoinColumn(name = "Artigo_cod", referencedColumnName = "cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Artigo artigo;

    public Avaliacao() {
    }

    public Avaliacao(AvaliacaoPK avalicacaoPK) {
        this.avalicacaoPK = avalicacaoPK;
    }

    public Avaliacao(int revisorcod, int artigocod, String notaC1, String notaC2, String notaC3) {
        this.avalicacaoPK = new AvaliacaoPK(revisorcod, artigocod, notaC1, notaC2, notaC3);
    }

    public AvaliacaoPK getAvaliacaoPK() {
        return avalicacaoPK;
    }

    public void setAvaliacaoPK(AvaliacaoPK avalicacaoPK) {
        this.avalicacaoPK = avalicacaoPK;
    }

    public Revisor getRevisor() {
        return revisor;
    }

    public void setRevisor(Revisor revisor) {
        this.revisor = revisor;
    }

    public Artigo getArtigo() {
        return artigo;
    }

    public void setArtigo(Artigo artigo) {
        this.artigo = artigo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (avalicacaoPK != null ? avalicacaoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Avaliacao)) {
            return false;
        }
        Avaliacao other = (Avaliacao) object;
        if ((this.avalicacaoPK == null && other.avalicacaoPK != null) || (this.avalicacaoPK != null && !this.avalicacaoPK.equals(other.avalicacaoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.femass.model.Avaliacao[ avalicacaoPK=" + avalicacaoPK + " ]";
    }

}
